# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Ben <ben@benmazer.net>

pkgname=fox
epoch=1
pkgver=1.6.57
pkgrel=3
pkgdesc="Free Objects for X: GUI Toolkit for C++"
arch=('loong64' 'x86_64')
url="http://www.fox-toolkit.org/"
license=('LGPL' 'custom')
depends=('bzip2' 'libxcursor' 'libxft' 'libxrandr' 'libxi' 'libpng' 'libtiff' 'glu')
makedepends=('mesa' 'gendesk' 'imagemagick')
optdepends=('perl')
source=(http://fox-toolkit.org/ftp/fox-$pkgver.tar.gz)
sha256sums=('65ef15de9e0f3a396dc36d9ea29c158b78fad47f7184780357b929c94d458923')

prepare() {
  cd "$srcdir"/${pkgname}-${pkgver}
  gendesk -n -f --pkgname=adie --pkgdesc="Fast and convenient programming text editor" --categories="Utility;TextEditor"
  gendesk -n -f --pkgname=calculator --name="FOX Calculator" --pkgdesc="Simple desktop calculator" --categories="Utility;Calculator"
  gendesk -n -f --pkgname=ControlPanel --name="FOX Desktop Setup" --pkgdesc="Setup desktop appearance for FOX applications" --categories="Settings;DesktopSettings"
  gendesk -n -f --pkgname=PathFinder --pkgdesc="File browser" --categories="System;FileTools;FileManager"
}

build() {
  cd "$srcdir"/${pkgname}-${pkgver}
  convert +set date:create +set date:modify adie/big_gif.gif adie.png
  convert +set date:create +set date:modify calculator/bigcalc.gif calculator.png
  convert +set date:create +set date:modify pathfinder/file_gif.gif PathFinder.png

  export CPPFLAGS="$CPPFLAGS -I/usr/include/freetype2"
  ./configure   --prefix=/usr \
                --enable-release \
                --with-xft=yes \
                --with-opengl=yes \
                --with-xim \
                --with-xshm \
                --with-shape \
                --with-xcursor \
                --with-xrender \
                --with-xrandr \
                --with-xfixes \
                --with-xinput
  make
}

package() {
  cd "$srcdir"/${pkgname}-${pkgver}
  make DESTDIR="$pkgdir" install

  pushd tests
  make ControlPanel
  install -m755 .libs/ControlPanel "$pkgdir"/usr/bin/
  popd

  install -Dm644 LICENSE_ADDENDUM "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

  install -dm755 "$pkgdir"/usr/share/{applications,pixmaps}
  install -m644 *.png "$pkgdir"/usr/share/pixmaps/
  install -m644 *.desktop "$pkgdir"/usr/share/applications/
}
